import type {
  OthersFrameworkConfig,
  PlatformElementConfig,
  StyleConfigMap,
} from '../../interfaces'
import { preprocessElementConfigs } from '../personalization'
import { COMMON_PAGE_ELEMENTS } from './common'

/**
 * 页面元素配置
 */
export const BILIBILI_PAGE_ELEMENTS: Record<string, PlatformElementConfig> = {
  ...COMMON_PAGE_ELEMENTS,
}
// 预处理配置
const PROCESSED_BILIBILI_ELEMENTS = preprocessElementConfigs(BILIBILI_PAGE_ELEMENTS)

export type BilibiliElements = typeof BILIBILI_PAGE_ELEMENTS
export type BilibiliElementKey = keyof typeof BILIBILI_PAGE_ELEMENTS
export type BilibiliElementValue = typeof BILIBILI_PAGE_ELEMENTS[BilibiliElementKey]

/**
 * 框架配置类型
 */
export type BilibiliFrameworkConfig = {
  [K in keyof OthersFrameworkConfig]: Partial<StyleConfigMap>
}

/**
 * 框架配置
 */
export const BILIBILI_FRAMEWORK_CONFIG: BilibiliFrameworkConfig = {
  GLOBAL: {
    elementHide: [
      PROCESSED_BILIBILI_ELEMENTS.PAGE_ELEMENTS,
    ],
  },
}
